﻿<!--#include file="../inc/easp/easp.asp"-->
<!--#include file="../inc/conn1.asp"-->
<!--#include file="../inc/checklogin.asp"-->
<!--#include file="../inc/easyide.asp"-->
<% CheckLogin("../index.asp") %>
<%
  If Session("Authority") = "1" Then
    Response.Write "<script type=""text/javascript"">alert('Delete failed!');top.location.href='index.asp';</script>"
  End if
%>
<%
  '删除配置文件
  dim y_id,g_id,Country,savepath
  y_id = Easp.Get("y_id")'获取要操作的国家的ID
  g_id = Easp.Get("g_id")'获取组ID
  Country = Easp.Get("Country")'获取要操作的国家名称
  
  '获取组文件路径
  dim rsgroup
  set rsgroup = Easp.db.GetRecordBySql("select * from [Group] where ID=" & g_id)
  if not Easp.IsN(rsgroup) Then
  	savepath = trim(rsgroup("SavePath"))
  	if right(savepath, 1) <> "/" and right(savepath, 1) <> "\" then
  	  savepath = savepath & "/"
    end if		
  end if
  Easp.db.C(rsgroup)
  
  '获取对应国家XMl文件名称
  dim rscountry
  set rscountry = Easp.db.GetRecordBySql("select * from Country where y_id=" & y_id)
  if not Easp.IsN(rscountry) then
  	dim filename
  	filename = Trim(rscountry("HolidayFile"))
  	if filename <> "" then
  	  filename = savepath & filename
  	  if file_exists(filename) then
  		  file_delete(filename)
      end if
    end if
  end if   
  Easp.db.C(rscountry)
  
  '清空字段
  dim result
  dim xmlfile
  xmlfile = ""
  result = Easp.db.UpdateRecord("Country", Array("y_id:" & y_id, "g_id:" & g_id), Array("HolidayFile:" & xmlfile))
  If result <> 0 Then   
    Response.Write "<script type=""text/javascript"">alert('Deleted successfully!');top.location.href='index.asp';</script>"
  Else
  	Response.Write "<script type=""text/javascript"">alert('Delete failed!');top.location.href='index.asp';</script>"
  End If 
%>